package csu.ssd.student;

import csu.ssd.student.Dao.studentDao;
import csu.ssd.student.vo.Student;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;

public class yuanController implements Initializable {

    @FXML
    private TableColumn<Student, String> kemu;
    @FXML
    private TableView<Student> yuan;
    @FXML
    private TableColumn<Student, Integer> paper;

    @FXML
    private TableColumn<Student, Integer> last;

    @FXML
    private Button shen;

    @FXML
    private TableColumn<Student, Integer> hao;

    @FXML
    private TableColumn<Student, Integer> pingshi;

    @FXML
    private ComboBox<String> shijian;

    private ObservableList<Student> RoleData = FXCollections.observableArrayList();

    @FXML
    void gai(ActionEvent event) {

        yuan.getItems().clear();
        studentDao m=new studentDao();
        List<Student> list= m.getRole();
        int mm=1;
        for (Student f : list) {

            if ( shijian.getValue().equals(f.getShi()))
            {
                RoleData.add(f);

                //finishtowait.setCellValueFactory(cellData ->cellData.getValue().cb.getCheckBox());
                kemu.setCellValueFactory(new PropertyValueFactory<>("kemu"));
                last.setCellValueFactory(new PropertyValueFactory<>("last"));
                paper.setCellValueFactory(new PropertyValueFactory<>("paper"));
                pingshi.setCellValueFactory(new PropertyValueFactory<>("pingshi"));
                //  finishren.setCellValueFactory(new PropertyValueFactory<>("name"));
                yuan.setItems(RoleData);

            }
        }

    }
    @FXML
    void bu(ActionEvent event) throws IOException {
         Stage stage =new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(Shouye.class.getResource("shen.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 800.0, 600.0);
        stage.setTitle("中南大学学生管理系统");

        stage.setScene(scene);
        stage.setMaxWidth(400.0);
        stage.setMaxHeight(400.0);
        stage.show();

    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        shijian.getItems().addAll("大一上", "大一下", "大二上", "大二下", "大三上","大三下","大四上","大四下");

    }
}
